#include<bits/stdc++.h>
using namespace std;
#include<queue>
#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define dep(i,a,n) for(int i=n;i<=a;i--)
const int INF = 1e9;
const int omp = 1e5;

    int maxmiumScore(vector<int>& cards, int cnt) {
        sort(cards.begin(), cards.end(), greater<int>());
        int res = 0, lastodd = 0, lasteven = 0;
        for (int i = 0; i < cnt; i++)
        {
            res += cards[i];
            if (cards[i] % 2 == 1) lastodd = cards[i];
            else lasteven = cards[i];
        }
        if (res % 2 == 0) return res;

        int max1 = 0, max2 = 0;
        for (int i = cnt; i < cards.size(); i++)
        {
            if (lasteven && max1 == 0 && cards[i]%2) max1 = res - lasteven + cards[i];
            if (lastodd && max2 == 0 && cards[i]%2 == 0) max2 = res - lastodd + cards[i];
        }
        return max(max1, max2);
    }

void solve(){
    vector<int> card={1,2,8,9};

     int cnt=3;
     cout<<maxmiumScore(card,cnt);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--)solve();
    return 0;
}
